#ifndef CTC_H_
#define CTC_H_

#include "typedefs.h"
#include "bsp.h"
#include "mrfi.h"
#include "nwk_types.h"
#include "nwk_api.h"
#include "nwk.h"

#define DEFAULT_RCR_SLEEP_TIME (15)
#define DEFAULT_RTS_SLEEP_TIME (30)
#define ACKNOWLEDGE (0xAA)
#define ACK_MESSAGE_LENGTH (3)
#define CLOSED (0)
#define OPEN (1)
#define NO_DEVICE_FOUND (0xFF)
#define RCR_IDENT (0)
#define RTS_IDENT (1)
#define RCR_REQ (2)
#define RTS_REQ (3)
#define KEEP_FRAME (0)
#define DISCARD_FRAME (1)

RCR_t* createNewRCR(linkID_t, zone_t, sleepTime_t, battLife_t);
RCR_t** deleteRCR(RCR_t**, uint8_t);
RCR_t** addNewRCR(RCR_t**, uint8_t, RCR_t*);
RTS_t* createNewRTS(linkID_t, zone_t, sleepTime_t, battLife_t);
RTS_t** deleteRTS(RTS_t**, uint8_t);
RTS_t** addNewRTS(RTS_t**, uint8_t, RTS_t*);
void updateRCR(RCR_t**, uint8_t, linkID_t, battLife_t);
void updateRTS(RTS_t**, uint8_t, linkID_t, temp_t, battLife_t);
void ackRCR(RCR_t**, uint8_t, linkID_t);
void ackRTS(RTS_t**, uint8_t, linkID_t);
uint8_t findRTSbyLinkID(RTS_t** RTSarray, uint8_t numRTSs, linkID_t linkID);
uint8_t findRCRbyLinkID(RCR_t** RCRarray, uint8_t numRCRs, linkID_t linkID);

uint8_t isRCR(RCR_t**, uint8_t, linkID_t);
uint8_t isRTS(RTS_t**, uint8_t, linkID_t);

#endif /*CTC_H_*/
